home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / OpenLinux 2.3 CD.iso / live / usr / lib / rpm-2.5.5 / freshen.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1999-08-10  |  881 b   |  45 lines

  1. #!/bin/sh
  2.  
  3. # Implements --freshen option in RPM. --freshen is mostly like upgrade, but
  4. # go through each file and make sure the package is actually installed before
  5. # upgrading it. This won't work properly if there are any odd options
  6. # specified (i.e. filenames with " specified). I'm sure some shell-hacker
  7. # out there can fix that <hint, hint>.
  8.  
  9. if [ $1 = ";" ]; then
  10.     RPM=rpm
  11.     shift
  12. else
  13.     RPM=$1
  14.     shift 2
  15. fi
  16.  
  17. args="-U"
  18. while [ $# -gt 0 ]; do
  19.     if [ "$1" = "--" ]; then
  20.     break
  21.     fi
  22.     args="$args $1"
  23.     shift
  24. done
  25.  
  26. if [ $# = 0 ]; then
  27.     exec $RPM $args
  28. fi
  29.  
  30. args="$args -- "
  31. shift
  32.  
  33. # Just filenames left now
  34. for n in $*; do
  35.     # if the file doesn't exist, we'll let RPM give the error message
  36.     if [ ! -f $n ]; then
  37.     args="$args $n"
  38.     else
  39.     name=`rpm --qf "%{NAME}" -qp $n`
  40.     $RPM -q $name >/dev/null 2>&1 && args="$args $n"
  41.     fi
  42. done
  43.  
  44. exec $RPM $args
  45.